package day_2022_7_to_8.day48;

/**
 * @author haomin
 * @date 2022/08/29 11:10
 **/
public class Day44_3_Offer04_FindNumberIn2DArray {
    class Solution {
        public boolean findNumberIn2DArray(int[][] matrix, int target) {
            if(matrix.length == 0 || matrix[0].length == 0) return false;
            int m = matrix.length, n = matrix[0].length;
            int row = 0, col = n - 1;
            while(row < m && col >= 0){
                if(matrix[row][col] < target){
                    row++;
                }else if(matrix[row][col] > target){
                    col--;
                }else return true;

            }
            return false;
        }
    }
}